
var vm = new Vue({
    el : "#xbkXjList",
    data : {
    },
    init:function(){
        var _self = this;
        layui.use(['layer'], function(){
            layer = layui.layer;
        });
    },
    methods: {
        getCkCode: function(event){
            var _self = this;
            var code = document.getElementById("sjCode").value;   //作业工单RFID

            if (event && (event.keyCode != 13 || !(code && code.length > 0))) {
                return;
            }
            _self.changeRfid(_self,code);
        },
        changeRfid: function(_self, code){

            var data ={
                code : code
            };
            _self.$nextTick(function() {
                _self.$http.post(host +"xbkXjList/selectXbkXjListByCode",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.xbkSjListData = res.body.xbkSjListByCode;
                        _self.PlanList = res.body.PlanList;
                       // _self.ListType = res.body.ListType;
                        _self.message = res.body.message;
                        if(_self.xbkSjListData == "false"){
                            _self.vueAlert("此RFID不存在！");
                           // document.getElementById("plancode").innerText="";
                          //  document.getElementById("xtcode").innerText="";
                          //  document.getElementById("flvalue").innerText="";
                            document.getElementById("wlcode").innerText="";
                            document.getElementById("inTime").innerText="";
                            document.getElementById("qtys").innerText=1;
                          //  $("#qtys").val("");
                            return;
                        }

                        /*if(_self.ListType != 'PLAN'){
                            $("#gdnum").hide();
                            document.getElementById("plancode").innerText="111111";
                            $("#xtnum").hide();
                            document.getElementById("xtcode").innerText="22222";

                        }else{
                            $("#gdnum").show();
                            $("#xtnum").show();
                        }
*/

                     //   document.getElementById("flvalue").innerText=_self.PlanList[0].FLNAME ;

                        document.getElementById("wlcode").innerText=_self.PlanList[0].WLNAME;

                        document.getElementById("inTime").innerText=_self.PlanList[0].TIMES;

                        document.getElementById("qtys").innerText=1;
                      //      $("#qtys").val(1);


                    }
                });
            });


        },
        saveRfidLists: function(){
            var _self =this;
            var code = document.getElementById("sjCode").value;   //作业工单RFID
            var qtys = '1';//document.getElementById("qtys").value;   //上架数量

            if(code == null || code == ""){
                this.vueAlert("RFID不能为空！");
                return;
            }

            /*if(qtys == null || qtys == ""){
                this.vueAlert("下架数量不能为空！");
                return;
            }*/
            var data ={
                code : code,
                qtys : qtys
            };
            _self.$nextTick(function() {
                _self.$http.post(host +"xbkXjList/saveXbkXjListByCode",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.xbkSjListData = res.body.xbkXjListData;
                        _self.message = res.body.message;
                        _self.result = res.body.result;
                        if(_self.xbkSjListData == "false"){
                            _self.vueAlert("此RFID不存在！");
                            return;
                        }else if(_self.result  == "false"){
                            _self.vueAlert("下架失败！");
                            return;
                        }else{
                            _self.vueAlert("下架成功！");
                            window.setTimeout(function() {
                                window.location.reload();
                            }, 1000);
                            return;
                        }
                    }
                });
            });


        },
        reset:function(data){
            window.location.reload();
        },
        vueAlert:function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        }
    }
});